/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __PICTUREFORMAT_LOADER_H__
#define __PICTUREFORMAT_LOADER_H__

#include <resource/ActiveMultithreaded.h>
#include "Decompressor.h"

namespace liba
{
namespace pictureformat
{

class Loader
{
	filesystem::String name;
	resource::ActiveMultithreaded res_bmp;
	resource::ActiveMultithreaded res_bmp_a;
	resource::ActiveMultithreaded res_ppm;
	resource::ActiveMultithreaded res_ppm_a;

	resource::ActiveMultithreaded res_jpg;

	resource::ActiveMultithreaded res_gif;
	resource::ActiveMultithreaded res_gif_a;

	resource::ActiveMultithreaded res_png;
	
#if defined(IPHONE_VERSION) || defined(SAMSUNG_VERSION) || defined(WIN32)
	resource::ActiveMultithreaded res_pvr;
#endif

	mutable Decompressor * decompressor; // TODO - remove mutable
	mutable Decompressor * decompressor_a; // TODO - remove mutable
	Format twin_format;
	int frame;
public:
	explicit Loader(const filesystem::String & name);
	~Loader();
	bool is_valid()const;
	bool is_ready()const;

	int get_width(int frame = 0)const;
	int get_height(int frame = 0)const;
	Format get_best_format()const;
	int get_frame_count()const;
	void reset(Format f, int frame = 0);
	void unpack_scanline(void * dst);
	void skip_scanline(int count);
};

} // namespace pictureformat
} // namespace liba
using namespace liba;


#endif //__PICTUREFORMAT_LOADER_H__
